import axios from 'axios';
import {actionType} from './index'

const changeLogin = () => ({
  type: actionType.LOGIN,
  data: true
});

export const login = (account, pwd) => {
  return (dispatch) => {
    axios.get('/api/login.json?account=' + account + '&pwd=' + pwd).then(res => {
      if (res.data.data) {
        dispatch(changeLogin())
      } else {
        alert('登录失败')
      }
    })
  }
};

export const logout = () => ({
  type: actionType.LOGOUT,
  data: false
});